package services;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;

import javax.swing.table.DefaultTableModel;

public class ConexionSql {
	
	//NO SE USA
	private static String url = "jdbc:mysql://localhost:3306/";    
    private static String driverName = "com.mysql.jdbc.Driver";   
    private static String username = "root";   
    private static String password = "ignacio";

		
		 public static void conectar() {
			 
		        System.out.println("-------- MySQL JDBC Connection Demo ------------");
		        try
		        {
		            Class.forName(driverName);
		        }
		        catch (ClassNotFoundException e) {
		            System.out.println("MySQL JDBC Driver not found !!");
		            return;
		        }
		        System.out.println("MySQL JDBC Driver Registered!");
		        Connection connection = null;
		        try {
		            connection = DriverManager
		                .getConnection(url,username,password);//, "root", "password");
		            System.out.println("SQL Connection to database established!");
		 
		        } catch (SQLException e) {
		            System.out.println("Connection Failed! Check output console");
		            return;
		        } finally {
		            try
		            {
		                if(connection != null)
		                    connection.close();
		                System.out.println("Connection closed !!");
		            } catch (SQLException e) {
		                e.printStackTrace();
		            }
		        }
		    }


}
